{include file="layout/layout" /}
<script src="__PUBLIC__/static/js/layer/laydate/laydate.js"></script>
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商户列表列表</h3>
                <h5>商户管理及审核</h5>
            </div>
            <ul class="tab-base nc-row">
                {foreach $inc as $k=>$v}
                <li><a href="{:url('shop/shop_list',['inc_type'=> $k])}" {if condition="$k eq $inc_type"}class="current"{/if}><span>{$v}</span></a></li>
                {/foreach}
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li>管理商户</li>
        </ul>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>所有区域商户</h3>
                <h5>(共{$list|count}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><a href=""><i class="fa fa-refresh"></i></a></div>
            <form class="navbar-form form-inline" id="search-form" method="get" action="{:url('shop/shop_list')}" onsubmit="return check_form();">
                <input  id="create_time" value="" type="hidden">
                <div class="sDiv">
                    <div class="sDiv2" style="margin-right: 10px;">
                        <input size="30" id="start_time" name="start_time" value="{$start_time}" placeholder="起始时间" class="qsbox" type="text">
                        <input class="btn" value="起始时间" type="button">
                    </div>
                    <div class="sDiv2" style="margin-right: 10px;">
                        <input size="30" id="end_time" name="end_time" value="{$end_time}" placeholder="截止时间" class="qsbox" type="text">
                        <input class="btn" value="截止时间" type="button">
                    </div>
                    <div class="sDiv2" style="margin-right: 10px;">
                        <input size="30" name="search_name" value="{$search_name}" placeholder="商户编号/商户名称" class="qsbox" style="width:300px" type="text">
                        <input class="btn" value="搜索" type="submit">
                    </div>
                    <!-- <div class="sDiv2">
                        <input size="30" name="bank_card" placeholder="收款账号" class="qsbox" type="text">

                    </div> -->
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th abbr="article_title" axis="col3" class="center" >
                            <div style="text-align: center; width: 100px;" class="">门店编号</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="" align="center">
                            <div style="text-align: center; width: 100px;" class="">门店名称</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 50px;" class="">审核状态</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 50px;" class="">商户状态</div>
                        </th>

                        <th abbr="article_show" axis="col5" class="" align="center">
                            <div style="text-align: center; width: 80px;" class="">门店电话</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 100px;" class="">登录账号</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 50px;" class="">店主姓名</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 80px;" class="">提点(%oo)</div>
                        </th>

                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 200px;" class="">门店地址</div>
                        </th>

                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 100px;" class="">总收入(元)</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="" align="center">
                            <div style="text-align: center; width: 80px;" class="">加入时间</div>
                        </th>

                        <th axis="col1" class="handle" align="center">
                            <div style="text-align: center; width: 250px;">操作</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton">
                    <a href="{:url('shop/dowload_excel')}">
                        <div class="excel" title="导出Excel">
                            <span><i class="fa fa-check"></i>导出Excel</span>
                        </div>
                    </a>
                </div>
                <!-- <div class="fbutton">
                    <a onclick="act_submit(2)">
                        <div class="add" title="拒绝提现">
                            <span><i class="fa fa-ban"></i>审核失败</span>
                        </div>
                    </a>
                </div>
                <div class="fbutton">
                    <a onclick="act_submit(3)">
                        <div class="add" title="无效作废">
                            <span><i class="fa fa-close"></i>无效作废</span>
                        </div>
                    </a>
                </div> -->
            </div>
            <div style="clear:both"></div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table>
                    <tbody>
                    {foreach $list as $v}
                    <tr data-id="2592">
                        <td class="" align="left">
                            <div style="text-align: center; width: 100px;">{$v.sp_number}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 100px;">{$v.sp_name}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 50px;">
                                {switch $v.sp_audit}
                                {case -1 }未通过审核{/case}
                                {case '0'}待审核{/case}
                                {case 1}通过审核{/case}
                                {default /}待审核
                                {/switch}
                            </div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 50px;">
                                {switch $v.sp_status}
                                {case 1 }正常{/case}
                                {case 2}冻结{/case}
                                {/switch}
                            </div>
                        </td>

                        <td class="" align="left">
                            <div style="text-align: center; width: 80px;">{$v.sp_phone}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 100px;">{$v.sp_username}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 50px;">{$v.sp_true_name}</div>
                        </td>

                        <td class="" align="left">
                            <div style="text-align: center; width: 80px;">{$v.sp_ratio}</div>
                        </td>

                        <td class="" align="left">
                            <div style="text-align: center; width: 200px;">{$v.merger_name}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 100px;">{$v.sp_income/100}</div>
                        </td>
                        <td class="" align="left">
                            <div style="text-align: center; width: 80px;">{$v.sp_create_time|date="y/m/d"}</div>
                        </td>

                        <td class="handle" align="center">
                            <div style="text-align: center; width: 150px; max-width:250px;">
                                <a class="btn blue" href="shop_detail?id={$v.sp_id}"><i class="fa fa-search"></i>详情</a>
                                <a class="btn blue" href="shop_upd?id={$v.sp_id}"><i class="fa fa-pencil-square-o"></i>编辑</a>
                                <a class="btn red" href="javascript:void(0)" data-id="2592" onclick="shopDelete(this,{$v.sp_id})"><i class="fa fa-trash-o"></i>删除</a>
                            </div>
                        </td>

                        <td class="" style="width: 100%;" align="">
                            <div>&nbsp;</div>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;">

            </div>
        </div>
        {$page|raw}
        <!--分页位置-->

        <div class="dataTables_paginate paging_simple_numbers"><ul class="pagination">

        </ul></div>

    </div>
</div>
<script>
    var SCOPE = {
        'del_url':"{:url('shop/delete_shop')}"
    }
</script>
<script>
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });
        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });

        laydate({
            elem: '#start_time', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            range: true
        });
        laydate({
            elem: '#end_time', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            range: true,
        });
    });

    /**
     * 删除商户
     * @param obj
     */
    function shopDelete(obj,id){
        $.ajax({
            url:SCOPE.del_url,
            dateType:'json',
            type:'post',
            data:{'id':id},
            success:function(msg){
                if(msg.code==1){
                    layer.alert(msg.msg);
                    $(obj).parents('tr').remove();
                }else{
                    layer.alert(msg.msg);
                }
            }
        })
    }

    function check_form(){
        var start_time = $.trim($('#start_time').val());
        var end_time =  $.trim($('#end_time').val());
        if(start_time == '' ^ end_time == ''){
            layer.alert('请选择完整的时间间隔', {icon: 2});
            return false;
        }
        if(start_time > end_time){
            layer.alert('开始时间必须小于或等于结束时间',{icon:2});
            return false;
        }
        if(start_time !== '' && end_time !== ''){
            $('#create_time').val(start_time+" - "+end_time);
        }
        if(start_time == '' && end_time == ''){
            $('#create_time').val('');
        }

        return true;
    }

    //批量操作提交
    function act_submit(wst) {
        var chks = [];

        $('input[name*=selected]').each(function(i,o){
            if($(o).is(':checked')){
                chks.push($(o).val());
            }
        })
        //alert(chks.length);
        if(chks.length == 0){
            layer.alert('少年，请至少选择一项', {icon: 2});return;
        }
        var can_post = false;
        var remark = "审核通过";
        if(wst != 1 ){
            layer.prompt({title: '请填写备注', formType: 2}, function(text, index){
                layer.close(index);
                remark = text;
                audit(chks , wst ,  remark);
            });
        }else{
            audit(chks , wst ,  remark);
        }
    }

    function audit(chks , wst ,  remark){
        $.ajax({
            type: "POST",
            url: "{:url('User/withdrawals')}",//+tab,
            data: {id:chks,status:wst,remark:remark},
            dataType: 'json',
            success: function (data) {
                alert(data);
                // if(data.status == 1){
                //     layer.alert(data.msg, {
                //         icon: 1,
                //         closeBtn: 0
                //     }, function(){
                //         window.location.reload();
                //     });
                // }else{
                //     //返回错误信息
                //     layer.alert(data.msg, {icon: 2,time: 3000});
                // }
            },
            error:function(){
                layer.alert('网络异常', {icon: 2,time: 3000});
            }
        });
    }
</script>
</body>
</html>